package com.rock.minibatis.session.defaults;

import com.rock.minibatis.config.Configuration;
import com.rock.minibatis.executor.Executor;
import com.rock.minibatis.executor.SimpleExecutor;
import com.rock.minibatis.session.SqlSession;
import com.rock.minibatis.session.SqlSessionFactory;

public class DefaultSqlSessionFactory implements SqlSessionFactory {

    private final Configuration configuration;

    public DefaultSqlSessionFactory(Configuration configuration){
        this.configuration = configuration;
    }

    public Configuration getConfiguration() {
        return this.configuration;
    }

    public SqlSession openSession() {
        Executor executor = new SimpleExecutor(configuration);
        SqlSession sqlSession = new DefaultSqlSession(configuration,executor);
        return sqlSession;
    }
}
